package com.jiangli.controller.user;

import com.jiangli.annotation.RateLimit;
import com.jiangli.dto.FeedbackDTO;
import com.jiangli.result.Result;
import com.jiangli.service.FeedbackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user/feedback")
@Slf4j
@Api(tags = "反馈接口")
public class FeedbackController {
    private final FeedbackService feedbackService;
    public FeedbackController(FeedbackService feedbackService) {
        this.feedbackService = feedbackService;
    }

    @RateLimit
    @PostMapping
    @ApiOperation("用户反馈接受")
    public Result<String> feedback(@RequestBody FeedbackDTO feedbackDTO)
    {
        try{
            if(feedbackService.feedback(feedbackDTO))
            return Result.success("成功");
            else
                return Result.success("接受已达上限");
        }
        catch (Exception e)
        {
            return Result.error(e.getMessage());
        }
    }


}
